(function(){
	var shoplist_demo=[{
		id:0,
		name:"西少爷肉夹馍",
		count:1,
	},{
		id:1,
		name:"呷哺呷哺",
		count:0,
	},{
		id:2,
		name:"海底捞",
		count:2,
	},{
		id:3,
		name:"汉拿山石锅拌饭",
		count:0,
	},{
		id:4,
		name:"汉拿山烤肉",
		count:0,
	},{
		id:5,
		name:"黄太吉",
		count:0,
	},{
		id:6,
		name:"犟小面",
		count:0,
	},{
		id:7,
		name:"小笼汤包",
		count:1,
	},{
		id:8,
		name:"伏牛堂",
		count:5,
	},{
		id:9,
		name:"炉鱼",
		count:0,
	},{
		id:10,
		name:"港丽",
		count:0,
	},{
		id:11,
		name:"KFC",
		count:0,
	},{
		id:12,
		name:"麦当劳",
		count:0,
	},{
		id:13,
		name:"火炉火",
		count:0,
	},{
		id:14,
		name:"姑姑宴",
		count:0,
	},{
		id:15,
		name:"渝是乎",
		count:0,
	},{
		id:16,
		name:"鸿毛饺子",
		count:0,
	},{
		id:17,
		name:"南京大排档",
		count:0,
	}];

	var ballotDetail=new Vue({
		el:"#ballot",
		data:{
			shoplist:shoplist_demo
		},
		computed:{
			jointime:function(){
				var temp=0;
				var list=this.shoplist;
				for(var i=0;i<list.length-1;i++){
					for(var j=i+1;j<list.length;j++){
						if(list[i].id>list[j].id){
							temp=list[i];
							list[i]=list[j];
							list[j]=temp;
						}
					}
				}
				return list;
			},
			popular:function(){
				var temp=0;
				var list=this.shoplist;
				for(var i=0;i<list.length-1;i++){
					for(var j=i+1;j<list.length;j++){
						if(list[i].count<list[j].count){
							temp=list[i];
							list[i]=list[j];
							list[j]=temp;
						}
					}
				}
				return list;
			},
			sumcount:function(){
				var sum=0;
				for(var i=0;i<this.shoplist.length;i++){
					sum+=this.shoplist[i].count;
				}

				return sum;
			}
		},
		methods:{
			percent:function(i){
				var p=(i/this.sumcount)*100;
				var str="width:"+p+"%";
				return str;
			},
			goBallot:function(bid){
				for(var i =0 ;i<this.shoplist.length;i++){
					if(this.shoplist[i].id==bid){
						this.shoplist[i].count++;
					}
				}
			}
		}
	});
})()